package com.bfl.mybatis.generator;

import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class StartUp {

    public static void main(String[] args) {

        try {

			List<String> warnings = new ArrayList<>();
			boolean overwrite = true;
			
			URL url = StartUp.class.getResource("/generatorConfig-custom.xml");
			File configFile = new File(url.getFile());
			ConfigurationParser cfgParser = new ConfigurationParser(warnings);
			Configuration config  = cfgParser.parseConfiguration(configFile);
			CustomShellCallback callback = new CustomShellCallback(overwrite);

			CustomMyBatisGenerator generator = new CustomMyBatisGenerator(config, callback, warnings);
			System.out.println("mybatis 代码生成开始。。。");
			generator.generate(null);
			for(String warning : warnings) {
				System.out.println(warning);
			}
			System.out.println("mybatis 代码生成结束。。。");
			
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
